/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wider.foundation.channel;

import com.wider.foundation.concurrency.Cancellable;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * This interface defines a standard (unified manner) for user to implement/use protocol-dependent Network Channel(s) a client
 * side perspective in the Client-Server model.
 * Within this framework, all operations are restricted in the Request-Response model, just like the HTTP case.
 * Response handling is in async. way, user SHOULD implement the <code>NetChannelResponseHandler</code> interface and mount the
 * implementation during issuing requests.
 * 
 * @author William Choi <avextk@gmail.com>
 */
public interface NetChannel {
    public void connect(String url)  throws MalformedURLException, IOException;
    public void disconnect(long await_time, TimeUnit unit) throws InterruptedException;
    public NetChannelRequest get(Map<Object, Object> params, NetChannelResponseHandler handler) throws IllegalStateException, MalformedURLException, IOException;
    public NetChannelRequest get(Map<Object, Object> params, NetChannelResponseHandler handler, int timeout) throws IllegalStateException, MalformedURLException, IOException;
    public NetChannelRequest post(Map<Object, Object> params, NetChannelResponseHandler handler) throws IllegalStateException, MalformedURLException, IOException;
    public NetChannelRequest post(Map<Object, Object> params, NetChannelResponseHandler handler,int timeout) throws IllegalStateException, MalformedURLException, IOException;
    public boolean isReady();
    public long getRequestCount();
}
